package com.hks360.car_treasure.util;

import android.os.CountDownTimer;
import android.widget.TextView;

/**
 * Created by rwq on 2016/3/23.
 */
public class TimerUtil {
    private static int Count = 60;
    private static CountDownTimer timer;
    public static void timerCancel(){
        if(timer != null){
            timer.cancel();
            Count = 60;
        }
    }

    public static void createTimer(long inFutrue,long interval, final TextView tv_code){

           timer = new CountDownTimer(inFutrue,interval){

            @Override
            public void onTick(long l) {
                Count-- ;
                tv_code.setText("重新发送(" + Count + ")");
            }
            @Override
            public void onFinish() {
                tv_code.setText("获取验证码");
                Count = 60;
                tv_code.setEnabled(true);
            }
        }.start();
    }

}
